<%@page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="html" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<html:header title="账户转账">

    <link rel="stylesheet" href="${baseUrl}css/public.css" media="all">

    <style type="text/css">
    </style>

    <script>
        jQuery(function () {
            fixTableOperatorButton();
        });





        layui.use(['form', 'table','laydate'], function () {
            let $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                laydate = layui.laydate,
                util = layui.util;



            renderTable();
            table.on('toolbar(table)', function (obj) {
                let data = obj.data;
                if (obj.event === 'add') {
                    openTab("新增转账","${baseUrl}funds/transferNew.action");
                }
            });

            table.on('tool(table)', function (obj) {
                let data = obj.data;
                if (obj.event === 'close') {
                    close(data);
                } else if (obj.event === 'detail') {
                    openTab("转账详情","${baseUrl}funds/transferDetail.action?id="+data.id);
                }
            });

            form.on('checkbox(noClose)', function (data) {
                table.reload('table',{where: genSearch(),page: {curr: 1 }});
            });

            form.on('submit(search)', function (data) {
                table.reload('table',{where: genSearch(),page: {curr: 1 }});
                return false;
            });

        });

        function renderTable() {
            layui.table.render({
                id:'table'
                , elem: '#table'
                ,toolbar: '#tableToolBar'
                ,defaultToolbar:[]
                , url: "${baseUrl}funds/transfer/getList.action?time="+(new Date()).valueOf()
                ,where : {
                    close :false,
                    time:(new Date()).valueOf()
                }
                , limit: 10
                , page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                    //,curr: 5 //设定初始在第 5 页
                    ,groups: 5 //只显示 5 个连续页码
                    ,first: false //不显示首页
                    ,last: false //不显示尾页
                }
                , done: function(res, curr, count){
                    setTableLineCss("table",res.data, "close", true, "font-gray-c2c2c2");
                }
                , cols: [[
                    {width:70,title:"序号",templet:function (d) {
                            return genTableIndex(d.close,"作废",d);
                        }},
                    {field: 'id', width: 10, title: 'ID',hide:true},
                    {width: 130, title: '门店',style:"font-size:12px;",
                        templet:function (d) {
                            return d.store.name;
                        }
                    },
                    {width: 130, title: '转出账户',style:"font-size:12px;",
                        templet:function (d) {
                            return d.outSettAccountVo.store.name + ">" + d.outSettAccountVo.name;
                        }
                    },
                    {field: 'outDate', width: 150, title: '转出日期',style:"font-size:12px;",
                        templet:function (d) {
                            return GMTToDate(d.outDate);
                        }
                    },
                    {width: 130, title: '转入账户',style:"font-size:12px;",
                        templet:function (d) {
                            return d.inSettAccountVo.store.name + ">" + d.inSettAccountVo.name;
                        }
                    },
                    {field: 'outDate', width: 150, title: '到账日期',style:"font-size:12px;",
                        templet:function (d) {
                            return GMTToDate(d.inDate);
                        }
                    },
                    {width: 120, title: '金额',style:"font-size:12px;",templet:function (d) {
                            return getPrice(d.amt);
                        }},
                    {width: 120, title: '手续费',style:"font-size:12px;",templet:function (d) {
                            return getPrice(d.handleFee);
                        }},
                    {width: 120, title: '经手人',style:"font-size:12px;",templet:function (d) {
                            return d.user.name;
                        }},
                    {field: 'remark', minWidth: 120, title: '备注',style:"font-size:12px;"},
                    {title: '操作', minWidth: 80, fixed:'right', templet: '#operBar'},
                ]]
            });
        }

        function close(data) {
            layer.confirm('是否作废?', {icon: 3, title:'作废账户转账'}, function(index){
                tipLoad("作废中..");
                post("${baseUrl}funds/transfer/close.action",{id:data.id}, function (resp) {
                    closeAll();
                    if (resp.code == 1){
                        renderTable();
                    } else {
                        errTip(resp.msg);
                    }
                });
            });
        }

        function genSearch() {
            let json = getFormJson($("#searchForm"));
            json.close = $('[name="noClose"]').next().hasClass("layui-form-checked") ? false:'';
            return json;
        }
    </script>

</html:header>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form layui-form-pane" action="" id="searchForm">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <input type="checkbox" name="noClose" title="不显示作废记录" lay-skin="primary" value="true" checked lay-filter="noClose">
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">其他信息</label>
                    <div class="layui-input-inline">
                        <input type="text" name="search" placeholder="账户、备注" style="font-size: 12px;width: 200px;" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <a class="layui-btn" lay-submit="" lay-filter="search">
                        <i class="layui-icon layui-icon-search"></i>
                    </a>
                </div>
            </div>
        </form>
        <hr/>

        <table class="layui-hide" id="table" lay-filter="table" lay-size="sm"></table>


        <script type="text/html" id="tableToolBar">
            <div class="layui-inline">
                <a class="layui-btn" lay-event="add">新增</a>
            </div>
        </script>

        <script type="text/html" id="operBar">
            <a class="layui-btn layui-btn-xs layui-btn-normal table-operator" lay-event="detail">详情</a>
            <a class="layui-btn layui-btn-xs layui-btn-danger table-operator" lay-event="close">作废</a>
        </script>
    </div>
</div>
</body>

<html:loading/>
</html>